home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Arashi 1.1 / Game Source / mtz / mtz src / gdefhelp < prev    next >
Encoding:
Text File  |  1993-01-30  |  2.0 KB  |  64 lines  |  [TEXT/KAHL]

  1. Ok, I am *tyring* to install a Gestalt selector.  I want to 
  2. install the 'SAVR' selector (or replace it if it exists)
  3. to trick Superclock into thinking a screen saver is active
  4. so it will disappear for a while.  I have already traded
  5. e-mail with the author and he has told me what values to 
  6. return, etc.  So I was following example 3-5 in IM6 pg 3-43.
  7. All works fine until the DisposHandle call at the end,
  8. then I get dumped into MacsBug.  If I comment it out
  9. my code works the way I want to.  Superclock does turn
  10. off.  I can even turn iut back on with another selector
  11. installation, again *without* calling DisposHandle.
  12. IM6 says the slector will stick around until a restart.
  13. So I am confused why the example calls DisposHandle
  14. and then it crashes for me.  sniff sniff
  15.  
  16. As specified in IM-6 ad the Think C manual, my callback
  17. routines are compiled as locked and system heap code
  18. resources, and like I said above they do seem to work.
  19.  
  20. So here is some of the code...
  21.  
  22. ProcPtr *oldGestaltFunction;
  23.  
  24. /* DisableSuperclock will set the Gestalt selector 'savr'     */
  25. /* to indicate that a screen saver, such as afterdark,         */
  26. /* is enabled already, thus superclock will                    */
  27. /* not attempt to draw on the playing surface.                */
  28. void DisableSuperClock()
  29. {
  30.     OSErr    myNewErr, myReplaceErr;
  31.     int        gstFuncRsrcID = 128;
  32.     Handle    gstFuncHandle;
  33.     int        SAVRTrouble = 130;
  34.     
  35.     gstFuncHandle = GetResource('GDEF', gstFuncRsrcID);
  36.     if(gstFuncHandle == 0)
  37.         Alert(SAVRTrouble,0);
  38.     else
  39.     {
  40.         DetachResource(gstFuncHandle);
  41.         myNewErr = NewGestalt('SAVR',*gstFuncHandle);
  42.         if(myNewErr != noErr)
  43.         {
  44.             myReplaceErr = ReplaceGestalt('SAVR', *gstFuncHandle, 
  45.                 oldGestaltFunction);
  46.             if(myReplaceErr != noErr)
  47.                 Alert(SAVRTrouble,0);
  48.         }
  49.     }
  50.     DisposHandle(gstFuncHandle); 
  51. }
  52.  
  53. main()
  54. {
  55.     DisableSuperClock();
  56.     
  57. I dont know if I have missed anything obvious, stupid, or
  58. what, but I have been banging my head on it for a few days
  59. so I dont think I will catch the trick by myself at this
  60. point.
  61.  
  62. Thanks for any help,
  63. Mike
  64.